var a = getApp();

Page({
    data: {
        isMember: "",
        page: 1
    },
    onLoad: function(a) {
        this.setData({
            card_id: a.id
        }), this.search();
    },
    tapchange: function(a) {
        console.log(a), this.setData({
            kid: a.detail.value
        });
    },
    goSearch: function() {
        this.setData({
            page: 1
        }), this.search();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (this.data.current_page >= this.data.last_page) wx.showToast({
            title: "没有更多了",
            icon: "none",
            duration: 1e3
        }); else {
            var a = this.data.page + 1;
            this.setData({
                page: a
            }), this.searchMore();
        }
    },
    onShareAppMessage: function() {},
    tapbtn: function() {
        var t = a.getNetAddresss("plugin.energy-cabin.frontend.user-terminal.add-family-member"), e = {
            card_id: this.data.card_id,
            family_user_id: this.data.kid
        };
        a._getNetWork({
            url: t,
            data: e,
            success: function(a) {
                var t = a.data;
                1 == t.result ? (console.log(t), wx.navigateBack({
                    delta: 1
                })) : wx.showToast({
                    title: t.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    search: function() {
        var t = a.getNetAddresss("plugin.energy-cabin.frontend.user-terminal.search-member"), e = this;
        a._getNetWork({
            url: t,
            data: {
                page: e.data.page
            },
            success: function(a) {
                var t = a.data;
                1 == t.result && (console.log(t), e.setData({
                    list: t.data.data,
                    current_page: t.data.data.current_page,
                    last_page: t.data.data.last_page
                }));
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    searchMore: function() {
        wx.showLoading({
            title: "加载中"
        });
        var t = a.getNetAddresss("plugin.energy-cabin.frontend.user-terminal.search-member"), e = this;
        a._getNetWork({
            url: t,
            data: {
                page: e.data.page
            },
            success: function(a) {
                var t = a.data;
                1 == t.result && (console.log(t), e.setData({
                    list: e.data.list.concat(t.data.data),
                    current_page: t.data.data.current_page,
                    last_page: t.data.data.last_page
                }), wx.hideLoading({
                    complete: function(a) {}
                }));
            },
            fail: function(a) {
                console.log(a), wx.hideLoading({
                    complete: function(a) {}
                });
            }
        });
    }
});